#ifndef REBOT_BATTERY_HPP
#define REBOT_BATTERY_HPP

#include <rclcpp/rclcpp.hpp>
#include <socketcan_interface/threading.h>
#include "agv_msgs/msg/bat_info.hpp"
#include "agv_msgs/msg/agv_mode.hpp"
#include "diagnostic_msgs/msg/diagnostic_array.hpp"
#include "event_manager.hpp"
#include "toolKit.hpp"

class RebotBattery : public rclcpp::Node
{
public:
  explicit RebotBattery();
  ~RebotBattery();

private:
  bool init();
  void mode_callback(const agv_msgs::msg::AGVMode::SharedPtr msg);
  void battery_low_check();
  void battery_info_cb(const can::Frame &msg);
  void timer_callback();

  rclcpp::Publisher<agv_msgs::msg::BatInfo>::SharedPtr battery_info_pub_;
  rclcpp::Subscription<agv_msgs::msg::AGVMode>::SharedPtr mode_sub_;
  rclcpp::TimerBase::SharedPtr timer_;

  can::DriverInterfaceSharedPtr driver_;
  can::FrameListenerConstSharedPtr frame_listener_;
  
  agv_msgs::msg::BatInfo battery_info_;
  agv_msgs::msg::AGVMode agv_mode_;
  
  CEventManager event_manager_;
  int low_limit_;
  int too_low_limit_;
};

#endif